<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<div class="bjui-pageContent">
	<c:if test="${empty info.id}">
	<form action="<%=request.getContextPath()%>/tea/seller/insert.do" data-toggle="validate" data-reload-navtab="true">
	</c:if>
	<c:if test="${not empty info.id}">
	<form action="<%=request.getContextPath()%>/tea/seller/update.do" data-toggle="validate" data-reload-navtab="true">
		<input type="hidden" name="id" value="${info.id}">
	</c:if>
        <div class="pageFormContent" data-layout-h="0">
            <table class="table table-condensed table-hover" width="100%">
                <tbody>
                	<tr>
			 			<td colspan="2">
	                        <label class="control-label x100">商家特权：</label>
	                        <select name="supportsIds" data-toggle="selectpicker" data-width="200" id="supportsIds" multiple>
	                        	<c:forEach items="${slist}" var="list">
	                        	<option value="${list.id}">${list.description}</option>	
	                        	</c:forEach>
	                        </select>
	                    </td>
		    		</tr>
                	<tr>
				 		<td colspan="2">
	                        <label class="control-label x100">名称：</label>
	                        <input type="text" name="name" value="${info.name}" size="60">
	                    </td>
		    		</tr>
					<tr>
				 		<td colspan="2">
	                        <label class="control-label x100">服务得分：</label>
	                        <input type="text" name="serviceScore" value="${info.serviceScore}" size="60">
	                    </td>
		    		</tr>
					<tr>
				 		<td colspan="2">
	                        <label class="control-label x100">等级率：</label>
	                        <input type="text" name="rankRate" value="${info.rankRate}" size="60">
	                    </td>
		    		</tr>
					<tr>
				 		<td colspan="2">
	                        <label class="control-label x100">评级数：</label>
	                        <input type="text" name="ratingCount" value="${info.ratingCount}" size="60">
	                    </td>
		    		</tr>
					<tr>
				 		<td colspan="2">
	                        <label class="control-label x100">分数：</label>
	                        <input type="text" name="score" value="${info.score}" size="60">
	                    </td>
		    		</tr>
		    		<tr>
				 		<td colspan="2">
                        	<label class="control-label x100">头像：</label>
	                    	<div style="display:inline-block; vertical-align:middle;">
						    	<div id="avatar_pic_up" data-toggle="upload" data-uploader="<%=request.getContextPath()%>/tea/ratings/springUpload.do"
							        data-file-size-limit="1024000000"
							        data-file-type-exts="*.jpg;*.png;*.gif;*.mpg"
							        data-multi="true"
							        data-on-upload-success="avatar_upload_success"
							        data-icon="cloud-upload"></div>
							    <input type="hidden" name="avatar" value="${info.avatar}" id="avatar_pic">
							</div>
							<span id="avatar_span_pic">
								<c:if test="${not empty info.avatar}">
								已上传图片：<img width="50" height="50" src="<%=request.getContextPath()%>/${info.avatar}">
								</c:if>
							</span>
	                    </td>
		    		</tr>
					<tr>
				 		<td colspan="2">
	                        <label class="control-label x100">图片：</label>
	                        <div style="display:inline-block; vertical-align:middle;">
						    	<div id="pics_pic_up" data-toggle="upload" data-uploader="<%=request.getContextPath()%>/tea/ratings/springUpload.do"
							        data-file-size-limit="1024000000"
							        data-file-type-exts="*.jpg;*.png;*.gif;*.mpg"
							        data-multi="true"
							        data-on-upload-success="pics_upload_success"
							        data-icon="cloud-upload"></div>
							    <input type="hidden" name="pics" value="${info.pics}" id="pics_pic">
							</div>
							<span id="pics_span_pic">
								<c:if test="${not empty info.pics}">
								已上传图片：<img width="50" height="50" src="<%=request.getContextPath()%>/${info.pics}">
								</c:if>
							</span>
	                    </td>
		    		</tr>
					<tr>
				 		<td colspan="2">
	                        <label class="control-label x100">信息：</label>
	                        <input type="text" name="infos" value="${info.infos}" size="60">
	                    </td>
		    		</tr>
					<tr>
				 		<td colspan="2">
	                        <label class="control-label x100">食物分数：</label>
	                        <input type="text" name="foodScore" value="${info.foodScore}" size="60">
	                    </td>
		    		</tr>
					<tr>
				 		<td colspan="2">
	                        <label class="control-label x100">交货时间：</label>
	                        <input type="text" name="deliveryTime" value="${info.deliveryTime}" size="60">
	                    </td>
		    		</tr>
					<tr>
				 		<td colspan="2">
	                        <label class="control-label x100">成交价：</label>
	                        <input type="text" name="deliveryPrice" value="${info.deliveryPrice}" size="60">
	                    </td>
		    		</tr>
					<tr>
				 		<td colspan="2">
	                        <label class="control-label x100">描述：</label>
	                        <input type="text" name="description" value="${info.description}" size="60">
	                    </td>
		    		</tr>
					<tr>
				 		<td colspan="2">
	                        <label class="control-label x100">公告：</label>
	                        <input type="text" name="bulletin" value="${info.bulletin}" size="60">
	                    </td>
		    		</tr>
					<tr>
				 		<td colspan="2">
	                        <label class="control-label x100">销售数量：</label>
	                        <input type="text" name="sellCount" value="${info.sellCount}" size="60">
	                    </td>
		    		</tr>
					<tr>
				 		<td colspan="2">
	                        <label class="control-label x100">最低价：</label>
	                        <input type="text" name="minPrice" value="${info.minPrice}" size="60">
	                    </td>
		    		</tr>
                </tbody>
            </table>
        </div>
    </form>
</div>
<div class="bjui-pageFooter">
    <ul>
        <li><button type="button" class="btn-close" data-icon="close">关闭</button></li>
        <li><button type="submit" class="btn-default" data-icon="save">保存</button></li>
    </ul>
</div>
<script type="text/javascript">
	var c = $("#supportsIds").children();
	var ids = '${info.supportsIds}'.split(",");
	for(var i=0; i<c.length; i++) {
		var v = $(c[i]).val();
		var b = $.inArray(v, ids);
		if(b>=0) {
			$(c[i]).attr("selected",true);
		}
	}
    function avatar_upload_success(file, data) {
        var json = $.parseJSON(data);
        $(this).bjuiajax('ajaxDone', json);
        if (json[BJUI.keys.statusCode] == BJUI.statusCode.ok) {
            $('#avatar_pic').val(json.filename);
            $('#avatar_span_pic').html('已上传图片：<img width="50" height="50" src="<%=request.getContextPath()%>/'+json.filename +'">');
        }
    }
    function pics_upload_success(file, data) {
        var json = $.parseJSON(data);
        $(this).bjuiajax('ajaxDone', json);
        if (json[BJUI.keys.statusCode] == BJUI.statusCode.ok) {
            $('#pics_pic').val(json.filename);
            $('#pics_span_pic').html('已上传图片：<img width="50" height="50" src="<%=request.getContextPath()%>/'+json.filename +'">');
        }
    }
</script>